package interfaces.menu.options;

import fileHandling.language.Lang;
import fileHandling.language.interfaces.OptionsWindowText;
import interfaces.GUISource;
import interfaces.language.LanguageButton;
import interfaces.menu.AbsMenu;
import interfaces.menu.MenuContent;

import org.fenggui.binding.render.ImageFont;
import org.fenggui.util.Color;
import org.fenggui.util.Dimension;

public class OptionsMenu extends MenuContent {
	
	public static final Color DEFAULT_LEFT_COLOR = new Color(180, 180, 180);
	
	private OptionSwitchContent tabSwitchContent;
	
	private ControlOptionsContent controlWindow;
	private CommonOptionsContent commonWindow;
	private GraphicOptionsContent graphicWindow;
	private SoundOptionsContent soundWindow;
	
	private ImageFont buttonFont;
	
	private Dimension optionContentSize;
	
	public OptionsMenu(AbsMenu menu) {
		super(menu);
		
		buttonFont = GUISource.bigFont;
		int tabWidth = getWidth() / 4;
		
		tabSwitchContent = new OptionSwitchContent(getWidth(), getHeight(), buttonFont, tabWidth);
		tabSwitchContent.setBGColors(DEFAULT_LEFT_COLOR, Color.LIGHT_GRAY);
		addWidget(tabSwitchContent);
		
		int w = getWidth() - tabWidth;
		int h = getHeight();
		optionContentSize = new Dimension(w, h);
		
		makeButtons();
		
		layout();
	}
	
	private void makeButtons() {
		controlWindow = new ControlOptionsContent(this, menu);
		addMenuButton(OptionsWindowText.Controls, controlWindow);
		
		commonWindow = new CommonOptionsContent(this, menu);
		addMenuButton(OptionsWindowText.Common, commonWindow);
		
		graphicWindow = new GraphicOptionsContent(this, menu);
		addMenuButton(OptionsWindowText.Graphics, graphicWindow);
		
		soundWindow = new SoundOptionsContent(this, menu);
		addMenuButton(OptionsWindowText.Sound, soundWindow);
	}
	
	private void addMenuButton(Lang text, OptionContent optionContent) {
		LanguageButton button = new LanguageButton(text, buttonFont);
		tabSwitchContent.getOptionTabContent().addMainButton(button, optionContent);
	}
	
	public OptionSwitchContent getOptionSwitchContent() { return tabSwitchContent; }
	
	public Dimension getOptionContentSize() { return optionContentSize; }
}